﻿#region Copyright ©2008-2010, Technische Universitaet Muenchen
// ====================================================================================================
//
// Last Changed by       $Author: then $
// Last Changed Date     $LastChangedDate: 2009-06-09 09:28:29 +0200 (Tue, 09 Jun 2009) $
// Last Changed Revision $Rev: 185 $
//
// ====================================================================================================
#endregion

namespace Tum.CollabXT
{
    /// <summary>
    /// Base interface for workflows. This interface connects static process model parts <see cref="IStaticProcessElement"/> and dynamic parts <see cref="IDynamicProcessElement"/>.
    /// </summary>
    public interface IWorkflow : IStaticProcessElement
    {
        /// <summary>
        /// Gets the activities assigned to the workflow.
        /// </summary>
        IWorkflowActivity[] Activities
        {
            get;
        }

        /// <summary>
        /// Gets the transitions assigned to the workflow.
        /// </summary>
        IWorkflowTransition[] Transitions
        {
            get;
        }

        /// <summary>
        /// Gets the start activity of the workflow.
        /// </summary>
        IWorkflowActivity Start
        {
            get;
        }

        /// <summary>
        /// Gets the current activity of the workflow.
        /// </summary>
        IWorkflowActivity Current
        {
            get;
        }

        /// <summary>
        /// Gets all possible transitions from the current activity.
        /// </summary>
        IWorkflowTransition[] CurrentTransitions
        {
            get;
        }

        /// <summary>
        /// Sets the workflow's start activity.
        /// </summary>
        /// <param name="start">Start activity.</param>
        void SetStart(IWorkflowActivity start);

        /// <summary>
        /// Sets the workflow's current activity.
        /// </summary>
        /// <param name="activity">New current activity.</param>
        void SetCurrent(IWorkflowActivity activity);

        /// <summary>
        /// Sets the workflow's current activity according to a selected transition <see cref="CurrentTransitions"/>.
        /// </summary>
        /// <param name="transition">Selected transition.</param>
        void SetCurrent(IWorkflowTransition transition);

        /// <summary>
        /// Adds a new transition to the workflow.
        /// </summary>
        /// <param name="transition">Transition to be added.</param>
        void AddTransition(IWorkflowTransition transition);

        /// <summary>
        /// Removes a transition from the workflow.
        /// </summary>
        /// <param name="transition">Transition to be removed.</param>
        void RemoveTransition(IWorkflowTransition transition);
    }

    /// <summary>
    /// This interface is a container for process elements <see cref="IProcessElement"/>, which are composed to a workflow.
    /// It contains input- and output products <see cref="IArtifact"/> and refers to all relevant activities <see cref="IActivity"/>.
    /// </summary>
    public interface IWorkflowActivity : IDynamicProcessElement
    {
       // TODO: pre- und postconditions mit aufnehmen
       // Bsp. Benötigt wird EingabeProdukt in bestimmtem Zustand
       // und Aktivität liefert Ausgabeprodukt in anderem Zustand

        /// <summary>
        /// Gets or sets the input products.
        /// </summary>
        IArtifact[] InputArtifacts
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets the output products.
        /// </summary>
        IArtifact[] OutputArtifacts
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets the relevant activities.
        /// </summary>
        IActivity[] Activities
        {
            get;
            set;
        }
    }

    /// <summary>
    /// This interface represents transitions in a workflow. It realizes 1:1 connections between workflow activities <see cref="IWorkflowActivity"/>.
    /// 1:N connections have to be realized using multiple instances of implementations of this interface, referring the same source activity.
    /// </summary>
    public interface IWorkflowTransition : IDynamicProcessElement
    {
        /// <summary>
        /// Gets or sets the transition's source activity.
        /// </summary>
        IWorkflowActivity SourceActivity
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets the transition's target activity.
        /// </summary>
        IWorkflowActivity TargetActivity
        {
            get;
            set;
        }
    }

    /// <summary>
    /// This interface is the base interface for dynamic process model elements.
    /// </summary>
    public interface IDynamicProcessElement : IProcessElement
    {
    }
}
